package com.kantboot.business.gc.repository;

import com.kantboot.business.gc.domain.dto.BusGcGame18nDTO;
import com.kantboot.business.gc.domain.entity.BusGcGameI18n;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface BusGcGameI18nRepository
        extends JpaRepository<BusGcGameI18n, Long> {


    /**
     * 根据语言编码和游戏id查询游戏国际化信息
     */
    BusGcGameI18n findByLanguageCodeAndGameId(String languageCode, Long gameId);

    @Query("""
            FROM BusGcGameI18n a
            WHERE
            (:#{#param.typeId} IS NULL OR a.gameId = :#{#param.typeId})
            """)
    Page<BusGcGameI18n> getLanguageListByTypeId(@Param("param")BusGcGame18nDTO param, Pageable pageable);
}
